//项目的请求接口
import request from "./request";


// post delete put用data

//登录
export function loginApi(data){
     return request({
          url:'login',
          method:'POST',
          data
     })
}

//侧边栏
export function AsideApi(){
     return request({
          url:'menus',
          method:'GET',
     })
}

//用户列表渲染
export function getusersApi(params){
     return request({
          url:'users',
          method:'GET',
          params
     })
}

//用户列表添加
export function  adduserApi(data){
      return request({
            url:'users',
            method:'POST',
            data
      })
}

//用户列表删除
export function deluserApi(id){
      return request({
            url:`users/${id}`,
            method:'DELETE',
      })
}

//用户列表编辑
export function bianuserApi(id,data){
      return request({
            url:`users/${id}`,
            method:'PUT',
            data
      })
}

//用户列表状态修改
export function xiuuserApi(uId,type){
     return request({
           url:`users/${uId}/state/${type}`,
           method:'PUT',
     })
}

//用户列表分配角色
export function jueseuserApi(id,rid){
       return request({
            url:`users/${id}/role`,
            method:'PUT',
            data:{rid}
       })
}























//角色列表渲染
export function getrolesApi(){
      return request({
            url:'roles',
            method:'GET'
      })
}


//角色列表添加
export function addrolesApi(data){
     return request({
           url:'roles',
           method:'POST',
           data
     })
}

//角色列表删除
export function delrolesApi(id){
       return request({
              url:`roles/${id}`,
              method:'DELETE',
       })
}

//角色列表编辑
export function bjrolesApi(id,data){ 
      return request({
             url:`roles/${id}`,
             method:'PUT',
             data
      })
}
//角色删除单个指定权限
export function  shanjueseApi(roleId,rightId){
      return request({
           url:`roles/${roleId}/rights/${rightId}`,
           method:'delete',
      })
 }

//角色列表修改权限
 export function xiurolesApi(roleId,rids){
       console.log(roleId,rids)
      return request({
            url:`roles/${roleId}/rights`,
            method:'POST',
            data:{rids}
      })
}





















//所有权限列表
export function getrightsApi(type){
        return request({
               url:`rights/${type}`,
               method:'GET'
        })
}

//商品管理商品列表
export function getgoodsApi(params){ 
       return request({
              url:'goods',
              method:'GET',
              params
       })
}

//商品管理  列表删除
export function delgoodsApi(id){
      return request({
             url:`goods/${id}`,
             method:'DELETE',
      })
}


//获取商品参数    级联框
export function getGoodsParamsApi(id,sel='many'){ 
      return request({ 
           url:`/categories/${id}/attributes`,
           method:"GET",
           params:{sel}
      }) 
 }

 //商品分类
export function getGoodsCateApi(params){
      return request({
           url:'/categories',
           method:'GET',
            params
      })
 }
//商品分类删除
export function delgoodsCateApi(id){
       return request({
              url:`categories/${id}`,
              method:'DELETE'
       })
}
// 获取统计图
export function getEcharts(params){
      return request({
            url:"reports/type/1",
            method:"GET",
            params
      })
}

//商品列表修改
export function xiuaddslistApi(id,data){
       return request({
              url:`goods/${id}`,
              method:'PUT',
              data
       })
}
//编辑级联框内容
export function bjjilianApi(id){
     return request({
            url:`goods/${id}`,
            method:'GET'
     })
}

 


















//商品管理  商品分类
 //编辑分类接口
export function editGoodsCateApi(cateId, catName) {
      return request({
        url: `categories/${cateId}`,
        method: 'PUT',
        data: { cat_name: catName }
      })
    }

    //商品分类
export function getGoodsCateListApi(params) {
      return request({
        url: '/categories',
        method: 'GET',
        params
      })
    }

    //商品列表接口
export function getGoodsListApi(params) {
      return request({
        url: '/goods',
        method: 'GET',
        params
      })
    }

    //添加商品接口
export function addGoodsApi(data) {
      return request({
        url: '/goods',
        method: 'POST',
        data
      })
    }

    //添加商品分类接口
export function addGoodsCateApi(data) {
      return request({
        url: '/categories',
        method: 'POST',
        data
      })
    }

//编辑提交参数
export function  bjGoodsparamsApi(cateId,attrId,data){
       return request({
              url:`categories/${cateId}/attributes/${attrId}`,
              method:'PUT',
              data
       })
}
//删除参数的接口
export function delgoodsparamsApi(id,attrid){
       return request({
              url:`categories/${id}/attributes/${attrid}`,
              method:'DELETE'
       })
}


//添加动态或者静态参数
export function addgoodsparamsApi(cateId,data){
      return request({
             url:`categories/${cateId}/attributes`,
             method:'POST',
             data
      })
}



























//订单渲染
export function getordersApi(params){
      console.log(params)
       return request({
              url:`orders`,
              method:'GET',
              params:{pagenum:params.pagenum,pagesize:params.pagesize,query:params.query}
       })
}